package com.css.fxfzysx.constants;

import com.css.fxfzysx.base.exception.ParamException;
import com.css.fxfzysx.util.PlatformObjectUtils;

import java.util.TreeMap;
public enum SrcFmckEnum {
    //混凝土强度等级
    CK13("C13", 9.6),
    CK15("C15", 11),
    CK18("C18", 13.3),
    CK20("C20", 15),
    CK23("C23", 17),
    CK25("C25", 18.5),
    CK28("C28", 20.6),
    CK30("C30", 22),
    CK35("C35", 26),
    CK40("C40", 29.5),
    CK45("C45", 32.5),
    CK50("C50", 35),
    CK55("C55", 37.5),
    CK60("C60", 39.5);


    private String code;
    private Double values;

    SrcFmckEnum(String code, double values) {
        this.code = code;
        this.values = values;
    }

    private static final TreeMap<String, SrcFmckEnum> B_SRC_ENUM_TREE_MAP = new TreeMap<>();

    static {
        for (SrcFmckEnum srcFmckEnum : SrcFmckEnum.values()) {
            B_SRC_ENUM_TREE_MAP.put(srcFmckEnum.code, srcFmckEnum);
        }
    }

    public static Double getBycode(String code) {
        if (PlatformObjectUtils.isEmpty(B_SRC_ENUM_TREE_MAP.get(code))) {
            throw new ParamException("所选参数未在定义范围内，请联系管理员！");
        }
        return B_SRC_ENUM_TREE_MAP.get(code).getValue();
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getCode() {
        return code;
    }

    public double getValue() {
        return values;
    }

    public void setValue(double values) {
        this.values = values;
    }
}
